

from selenium.webdriver.common.by import By

from base.page_base import BasePage


class LoanApplication(BasePage):
    cut=(By.XPATH, "//em[text()='借款账户']")
    apply =(By.LINK_TEXT, "申请额度")
    lim=(By.XPATH,"/html/body/div[1]/div[2]/div[3]/div/div/div[3]/form/div[2]/input")
    message=(By.NAME, "remark")
    verification_code=(By.ID, "verifycode")
    click_button=(By.CSS_SELECTOR, ".btn-submit.btn-md")
    money_location=(By.XPATH,'//*[@id="amount_list"]/tr/td[3]')
    def click_cut(self):
        self.base_click(self.cut)
    def click_apply(self):
        self.base_click(self.apply)
    def input_limit(self,limit):
        self.base_input(self.lim,limit)
    def input_message(self,message):
        self.base_input(self.message,message)
    def input_verification(self,cation):
        self.base_input(self.verification_code,cation)
    def click_buton(self):
        self.base_click(self.click_button)
    def get_success_text(self):
        return self.fd_element(self.money_location).text


    def loan_flow(self,limit,message,cation):
        self.click_cut()
        self.click_apply()
        self.input_limit(limit)
        self.input_message(message)
        self.input_verification(cation)
        self.click_buton()